package com.zy.ivideo.controller;

import com.zy.ivideo.entity.AgreeEntity;
import com.zy.ivideo.entity.ResponseEntity;
import com.zy.ivideo.service.AgreeService;
import com.zy.ivideo.token.UserToken;
import com.zy.ivideo.utils.ResponseUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/agree")
@Api(value = "点赞模块API接口", description = "该模块提供点赞模块服务", tags = "点赞模块")
public class AgreeController {
    @Autowired
    AgreeService service;

    /**
     * 点赞
     *
     * @param entity
     * @return
     */
    @UserToken
    @ApiOperation(value = "点赞", notes = "点赞", httpMethod = "PUT")
    @PutMapping("/agree")
    public ResponseEntity<AgreeEntity> agree(@RequestBody
                                             @ApiParam(value = "点赞实体", name = "entity", required = true)
                                                     AgreeEntity entity) {
        return service.agree(entity);
    }

    /**
     * 取消点赞
     *
     * @param entity
     * @return
     */
    @UserToken
    @ApiOperation(value = "取消点赞", notes = "取消点赞", httpMethod = "DELETE")
    @DeleteMapping("/unagree")
    public ResponseEntity<Boolean> unAgree(@RequestBody
                                               @ApiParam(value = "点赞实体", name = "entity", required = true)
                                                       AgreeEntity entity) {
        return service.unAgree(entity);
    }

}
